package com.yuncheng.spcyApi.controller;

import com.yuncheng.spcyApi.alog.annotation.Log;
import com.yuncheng.spcyApi.bo.ParamsBo;
import com.yuncheng.spcyApi.entity.SpcyRsIcon;
import com.yuncheng.spcyApi.service.ISpcyRsIconService;
import com.yuncheng.vo.HttpResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;

@Api(tags = "系统icon图标-接口")
@RestController
@RequestMapping(value = "/api/spzx-spcy/icon")
public class SpcyRsIconController {

    @Resource
    private ISpcyRsIconService spcyRsIconService;

    @Log(title = "icon图标-分页查询")
    @ApiOperation(value = "icon图标-分页查询")
    @GetMapping(value = "queryPageIcon")
    public HttpResult queryPageIcon(SpcyRsIcon icon,
                                    @RequestParam(value = "pageNo",defaultValue = "1")Integer pageNo,
                                    @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize){

        return HttpResult.ok(spcyRsIconService.queryPageIcon(icon, pageNo, pageSize));
    }

    @Log(title = "获取icon图标列表")
    @ApiOperation(value = "获取icon图标列表")
    @GetMapping(value = "queryIconList")
    public HttpResult queryIconList(SpcyRsIcon icon){

        return HttpResult.ok(spcyRsIconService.queryListIcon(icon));
    }

    @Log(title = "添加icon图标")
    @ApiOperation(value = "添加icon图标")
    @PostMapping(value = "addIcon")
    public HttpResult addIcon(@RequestBody SpcyRsIcon icon){
        SpcyRsIcon addIcon = spcyRsIconService.addIcon(icon);

        HttpResult result = new HttpResult(true);
        result.setMessage("保存成功");
        result.setResult(addIcon);
        return result;
    }

    @Log(title = "更新icon图标")
    @ApiOperation(value = "更新icon图标")
    @PutMapping(value = "updateIcon")
    public HttpResult updateIcon(@RequestBody HashMap<String,Object> paramMap){

        spcyRsIconService.updateIcon(paramMap);
        return HttpResult.ok("保存成功");
    }

    @Log(title = "批量删除icon图标")
    @ApiOperation(value = "批量删除icon图标")
    @PostMapping(value = "deleteIcon")
    public HttpResult deleteIcon(@RequestBody ParamsBo paramsBo){

        spcyRsIconService.deleteIcon(paramsBo);
        return HttpResult.ok("删除成功");
    }


}
